var table;
$(function(){
    table=$("#statistics").DataTable({
        "ajax": {
            url:"../../admin/annualpara/Get",
            type:"POST",
            data:function(d){
                d.annual_name=$("#search_annualname").val()
                d.start_date=$("#search_startdate").val()
                d.end_date=$("#search_enddate").val()
            },error:function(XMLHttpRequest,textStatus,errorThrown){
                console.log("载入数据出错");
            }
        },
        "scrollX": 1200,
        "bProcessing": true,
        "bServerSide": true,
        "bPaginate": true,
        "bAutoWidth": false,
        "bInfo": true,//页脚信息
        "bFilter": false,//禁用搜索
        "bSort":false,//禁用排序
        "aLengthMenu": [2,5,10],
        "sPaginationType":'full_numbers',
        "columns": [
            {"data":"id"},
            { "data": "annual_name" },
            { "data": "start_date" },
            { "data": "end_date" },
            { "data": "t_total" },
            { "data": "t_no_check" },
            { "data": "t_no_annual" },
            { "data": "t_pass" },
            { "data": "t_no_pass" },
        ],
        "aoColumnDefs": [

        ],
        "fnRowCallback": function (nRow, aData, iDisplayIndex) {
            $("td:first", nRow).html(iDisplayIndex + 1);
            return nRow;
        },
        "oLanguage": {
            "sProcessing": "处理中...",
            "sLengthMenu": "每页 _MENU_ 条",
            "sZeroRecords": "没有匹配结果",
            "sInfo": " _START_ 至 _END_ 项结果，共 _TOTAL_ 项",//显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项
            "sInfoEmpty": "",//显示第 0 至 0 项结果，共 0 项
            "sInfoFiltered": "",//(由 _MAX_ 项结果过滤)
            "sInfoPostFix": "",
            "sSearch": "搜索：",
            "sUrl": "",
            "sEmptyTable": "没有数据呀!",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页"
            }
        },
    });
})

function searchPara() {
    if($("#search_startdate").val()!=""&&$("#search_enddate").val()!="")
    {
        if($("#search_startdate").val()>$("#search_enddate").val()){
            Lobibox.notify('error', {
                msg: "开始时间大于结束时间",
                sound: false
            });
            return false
        }
    }
    table.draw();
}

function searchCert() {
    $.ajax({
        url:"../../admin/annualpara/certStat",
        type:"GET",
        error:function(XMLHttpRequest,textStatus,errorThrown){
            console.log("载入数据出错");
        },
        success:function (data) {
            if (!data) {
                Lobibox.notify('error', {
                    msg: '空数据',
                    sound: false
                });
            }
            else
            {
                $.each(data, function (i,item) {
                    if(i==0){
                        $("#cert_valid").text(item);
                    }
                    if(i==1){
                        $("#cert_pause").text(item);
                    }
                    if(i==2){
                        $("#cert_cancel").text(item);
                    }
                    if(i==3){
                        $("#cert_total").text(item);
                    }
                });
                $("#certStat").modal("show")
                // Lobibox.notify('success', {
                //     msg: '成功',
                //     sound: false
                // });
            }
        }
    });
}